import * as types from './mutation-type'
const mutations = {
  [types.INCREMENT](state, n) {
    state.count += n
  },
  [types.CHANGE_NAME](state) {
    state.name = '小小红'
  },
  [types.ADD_TO_ITEMS](state, shop) {
    state.items.push({
      id: shop.id,
      title: shop.title,
      num: 1,
    })
  },
  [types.ADD_ITEM_NUM](state, shop) {
    const product = state.items.find((e) => e.id === shop.id)
    product.num++
  },
}

export default mutations
